<%@page contentType="text/html;charset=utf-8"%>
<%@include file="../../core/common.jsp"%>
<%@include file="../plugins/ys.jsp"%>
<html>
<head>
<title></title>
</head>
<script>
	function rkfx_(value, row, index) {
		var mx = template("rkfx_ys", {
			list : row.mx
		});
		return mx;
	}
	function ckfx_(value, row, index) {
		var mx = template("ckfx_ys", {
			list : row.mx
		});
		return mx;
	}
	function pcfx_(value, row, index) {
		var mx = template("pcfx_ys", {
			list : row.mx
		});
		return mx;
	}
	var rkzts = $.loadOption('${CTX}/mgt/sys/dict/option/rkzt');
	function rkzt_(value, row, index) {
		return rkzts[value];
	}
</script>
<body>
	<div id="tb" class="toolbar">
		<form id="fm">
			<table class="form-layout w80">
				<tr>
					<td>产品编号：</td>
					<td><input name="search_cpbh" class="easyui-textbox" /></td>
					<td>规格型号：</td>
					<td><input name="search_ggxh" class="easyui-combobox" data-options="url:'${CTX}/mgt/sys/dict/value/ph',editable:false,formatter:''" /></td>
					<td>入库期起：</td>
					<td><input name="search_begin" class="easyui-datebox" data-options="editable:false" /></td>
					<td>入库期止：</td>
					<td><input name="search_end" class="easyui-datebox" data-options="editable:false" /></td>
				</tr>
			</table>
		</form>
		<div style="float: left;">
			<shiro:hasPermission name="fxd:rkfx">
				<a id="rkfx" class="form-btn primary">
					<i class="fa fa-bar-chart m-r-5"></i>入库分析
				</a>
			</shiro:hasPermission>
			<shiro:hasPermission name="fxd:ckfx">
				<a id="ckfx" class="form-btn primary">
					<i class="fa fa-bar-chart m-r-5"></i>出库分析
				</a>
			</shiro:hasPermission>
		</div>
		<div style="float: right;">
			<a id="find" class="form-btn success">
				<i class="fa fa-search m-r-5"></i>查询
			</a>
			<a id="reset" class="form-btn default">
				<i class="fa fa-undo m-r-5"></i>重置
			</a>
		</div>
		<div style="clear: both;"></div>
	</div>
	<table id="dg" class="easyui-datagrid" data-options="url:'${CTX}/mgt/t/fxd/find',toolbar:'#tb',pagination:true">
		<thead>
			<tr>
				<th data-options="field:'cpbh',width:100">产品编号</th>
				<th data-options="field:'ggxh',width:80">规格型号</th>
				<th data-options="field:'rkzt',width:80,formatter:rkzt_">入库状态</th>
				<th data-options="field:'rkrq',width:100">入库日期</th>
				<th data-options="field:'rkfx',width:250,formatter:rkfx_">入库分析</th>
				<th data-options="field:'ckfx',width:250,formatter:ckfx_">出库分析</th>
				<th data-options="field:'pcfx',width:250,formatter:pcfx_">偏差分析</th>
				<th data-options="field:'fxsj',width:100">分析时间</th>
				<th data-options="field:'jcz',width:100">检查者</th>
				<th data-options="field:'qrz',width:100">确认者</th>
			</tr>
		</thead>
	</table>
</body>
<script>
	$(function() {
		$('#find').click(function() {
			$('#dg').datagrid('reload', $('#fm').serializeObject());
		});
		$('#reset').click(function() {
			$('#fm').form('reset');
			$('#find').click();
		});
		$('#rkfx').click(function() {
			var row = $('#dg').datagrid('getSelected');
			if (row) {
				$.open({
					title : $(this).html(),
					url : '${CTX}/mgt/t/fxd/rkfx?cpbh=' + row.cpbh,
					end : function() {
						$('#find').click();
					}
				});
			} else {
				$.info('请选择入库单');
			}
		});
		$('#ckfx').click(function() {
			var row = $('#dg').datagrid('getSelected');
			if (row) {
				if (row.mx.length == 0) {
					$.info('请先输入入库分析');
				} else {
					$.open({
						title : $(this).html(),
						url : '${CTX}/mgt/t/fxd/ckfx?cpbh=' + row.cpbh,
						end : function() {
							$('#find').click();
						}
					});
				}
			} else {
				$.info('请选择入库单');
			}
		});
	});
</script>
</html>